use "dataset_other_louisiana_parishes", clear

replace parish = subinstr(parish, " parish", "", 1)
replace parish = subinstr(parish, ", louisiana", "", 1)

local i = 1
levelsof parish, local(parishes)
foreach parish of local parishes {

	local mygraphs

	local j = word("`c(alpha)'", `i')
	
	preserve

		keep if parish == "`parish'"
		
		gen pctyes_post = pctyes if year >= 2020
		
		levelsof year, local(levels)
		foreach year of local levels {
		
			su pctblack if year == `year'
			gen x = (pctblack - r(min)) / (r(max) - r(min))
			reg pctyes x [aw=totalvotes] if year == `year', robust
			local b = string(_b[x], "%20.02fc")
			local se = string(_se[x], "%20.02fc")
			drop x
		
			#delimit;
			
			gr tw
				(sc pctyes pctblack [aw=totalvotes] 
					if year==`year', msym(Oh) msize(tiny))
				(sc pctyes_post pctblack [aw=totalvotes] 
					if year==`year', msym(O) msize(tiny))
				(lpoly pctyes pctblack [aw=totalvotes] 
					if year==`year', lcol(black) 
					lwid(thick))
				,
					legend(off)
					plotregion(style(none))
					ylab(, angle(horiz))
					xtitle("")
					ytitle("")
					title(`year')
					name(g`year', replace)
					subtitle({&beta} = `b' (`se'),
						size(small))
					nodraw
					;
			
			#delimit cr
		
			local mygraphs `mygraphs' g`year'
			
		}
		
		gr combine `mygraphs', cols(7) title("`parish'") ///
			b1title("Share Black") l1title("Share Yes Vote") ///
			imargin(zero) ycommon xsize(2) ysize(1)

		gr export "_output/figure A26 `j'.pdf", replace
		
		gr close

	restore
	
	local i = `i' + 1

}

